/*==========================================================================*/
/*                             nms_v5.h                                  */
/*                                                                          */
/*   This is the include file for V5 library structures,                */
/*                      commands, error codes.                              */
/*                                                                          */
/*                                                                          */
/* Copyright (c)2001 NMS Communications. All rights reserved.               */
/*==========================================================================*/

#ifndef _NMSV5LIB_H_
#define _NMSV5LIB_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "nmstypes.h"

#define NMS_V5_INTERFACE_GROUPS              254
#define NMS_V5_CHANNEL_LOCATIONS             48
#define NMS_V5_E1_LOCATIONS                  16
#define NMS_V5_RX_BUFFER_SIZE                260
#define NMS_V5_TX_BUFFER_SIZE                260
#define NMS_V5_MIN_TRACE_BUF_SIZE            350

typedef DWORD       NMS_V5_INTERFACE_ID_T;
typedef DWORD       NMS_V5_CHANNEL_EVENT_T;
typedef DWORD       NMS_V5_E1_STATUSMASK_T;
typedef BOOL        NMS_V5_SA7_VALUE_T;
    
typedef enum _NMS_V5_BOARD_T
{
    NMS_BOARD_FAMILY_CG               = 0x01   /* Falcon Generation Family     */
} NMS_V5_BOARD_FAMILY_T;

typedef union _NMS_V5_E1_LOCATION_T
{
    struct {
        DWORD   boardNb;
        DWORD   trunkNb;
    } CG; 
} NMS_V5_E1_LOCATION_T;

typedef union _NMS_V5_CHANNEL_LOCATION_T
{
    struct {
        DWORD  boardNb;
        DWORD  trunkNb;
        DWORD  timeslotNb;
    } CG;    
} NMS_V5_CHANNEL_LOCATION_T;

                    /* Channel Event values */
#define    NMSV5_EVENT_RX_SUCCESS               0x1
#define    NMSV5_EVENT_RX_ERROR                 0x2
#define    NMSV5_EVENT_RX_FIFO_OVERRUN          0x3
#define    NMSV5_EVENT_RX_ABORT                 0x4
#define    NMSV5_EVENT_RX_CRC_ERROR             0x5
#define    NMSV5_EVENT_RX_NON_ALIGNED_OCTET     0x6
#define    NMSV5_EVENT_RX_BUFFER_OVERFLOW       0x7
#define    NMSV5_EVENT_RX_NO_7E_FLAG            0x8
#define    NMSV5_EVENT_TX_ERROR                 0x9
#define    NMSV5_EVENT_TX_FIFO_UNDERRUN         0xA
#define    NMSV5_EVENT_TX_FIFO_OVERRUN          0xB
#define    NMSV5_EVENT_TX_QUEUE_FULL            0xC

typedef void( *NMS_V5_CHANNEL_CALLBACK_T )(
                            NMS_V5_INTERFACE_ID_T interfaceId,
                            NMS_V5_CHANNEL_LOCATION_T channel_loc, 
                            NMS_V5_CHANNEL_EVENT_T channel_event,
                            void *databuffer, 
                            DWORD datasize);

typedef void( *NMS_V5_TRACE_CALLBACK_T )(char *tracebuffer, DWORD datasize);

typedef void( *NMS_V5_E1_STATUS_CALLBACK_T )(
                            NMS_V5_INTERFACE_ID_T interfaceId,
                            NMS_V5_E1_LOCATION_T e1_loc,
                            NMS_V5_E1_STATUSMASK_T status_event); 

typedef enum _NMS_V5_RESULT_T
{
    NMSV5_SUCCESS                   = 0x00,  /* Success                          */
    NMSV5_INVALID_PARMS             = 0x01,  /* Invalid parameters               */
    NMSV5_ALREADY_INITIALIZED       = 0x02,  /* Library already initilized       */
    NMSV5_FAILED_LOAD_LIB           = 0x03,  /* Failed to load library           */ 
    NMSV5_NO_MEMORY                 = 0x04,  /* Failed to allocate host memory   */
    NMSV5_INTERNAL_FAILURE          = 0x05,  /* Operation failed.(See log info)  */
    NMSV5_NOT_INITIALIZED           = 0x06,  /* Library not initialized          */ 
    NMSV5_INVALID_INTERFACE_ID      = 0x07,  /* Unknown interface id             */ 
    NMSV5_INVALID_CHANNEL           = 0x08,  /* Invalid channel location         */
    NMSV5_INVALID_E1                = 0x09,  /* Invalid E1 location.             */
    NMSV5_OUTOFRESOURCE             = 0x0a,  /* No more resources available      */
    NMSV5_INVALID_STATE             = 0x0b,  /* Invalid state for request        */
    NMSV5_NO_STANDBY                = 0x0c  /* No standby variant defined       */
} NMS_V5_RESULT_T;

typedef enum _NMS_V5_TRACEMASK_T
{
    NMSV5_TRACEMASK_NONE            = 0x00,
    NMSV5_TRACEMASK_FUNCTIONS       = 0x01,  
    NMSV5_TRACEMASK_ERRORS          = 0x02,
	NMSV5_TRACEMASK_RX_BUF          = 0x04,  
    NMSV5_TRACEMASK_TX_BUF          = 0x08,
	NMSV5_TRACEMASK_HDLC_ERR        = 0x10,
	NMSV5_TRACEMASK_E1_STATUS       = 0x20,
    NMSV5_TRACEMASK_ALL             = 0xffff
} NMS_V5_TRACEMASK_T;

/*============================ Data Structures ============================ */

                       /* E1 StatusMask values                 */  
#define NMSV5_E1_LOS                0x001  /* Loss of signal                       */
#define NMSV5_E1_LOF                0x002  /* Loss of frame                        */
#define NMSV5_E1_AIS                0x004  /* Alarm indication signal              */
#define NMSV5_E1_RAI                0x008  /* Remote alarm indication              */
#define NMSV5_E1_CRC_BLOCK_ERR      0x010  /* CRC block error                      */
#define NMSV5_E1_CRC_BLOCK_INFO     0x020  /* CRC block info (Febe)                */
#define NMSV5_E1_NORMAL_FRAMES_0    0x040  /* Normal E1 frames                     */ 
#define NMSV5_E1_NORMAL_FRAMES_1    0x080  /* Normal E1 frames                     */
 

                       /* E1 Status structure */
typedef struct {
    DWORD Size;                                 /* Size of this structure               */
    NMS_V5_E1_STATUSMASK_T StatusMask;          /* Current E1 status bit mask           */
    DWORD Slips;                                /* Slips                                */
    DWORD Es;                                   /* Errors seconds                       */
    DWORD Ses;                                  /* Severely errored seconds             */
    DWORD Uas;                                  /* Unavailable seconds                  */
    DWORD LineErrors;                           /* Line code violations                 */
    DWORD FrameErrors;                          /* Frame bit errors and CRC errors      */
    DWORD ElaspedTime;                          /* Seconds since counters started       */
} NMS_V5_E1_STATUS_T;

                 /* HDLC channel statistics structures */
typedef struct {
    DWORD Octets;                 /* Bytes received count                   */
    DWORD Frames;                 /* Frames received count                  */
    DWORD Drops;                  /* Frames dropped count                   */
    DWORD FifoOverruns;           /* Fifo overrun count                     */
    DWORD Aborts;                 /* Receive abort count                    */
    DWORD CrcErrors;              /* Receive CRC errors count               */
    DWORD NonAlignedOctets;       /* Non-Aligned Octets count               */
    DWORD BufferOverflows;        /* Buffer Overflows count                 */
} CHANNEL_STATISTICS_RECEIVE_T;

typedef struct {
    DWORD Octets;                 /* Bytes transmitted count                */
    DWORD Frames;                 /* Frames transmitted count               */
    DWORD Drops;                  /* Frames dropped count                   */
    DWORD FifoUnderruns;          /* Fifo underrun count                    */
    DWORD FifoOverruns;           /* Fifo overrun count                     */
} CHANNEL_STATISTICS_TRANSMIT_T;

typedef struct {
    DWORD Size;                                 /* Size of this structure   */
    CHANNEL_STATISTICS_RECEIVE_T  chan_stat_rx; /* Receive statistics       */
    CHANNEL_STATISTICS_TRANSMIT_T chan_stat_tx; /* Transmit statistics      */      
} NMS_V5_CHANNEL_STATISTICS_T;

/*==========================================================================*/
/* Initialize the board family specific library */
NMS_V5_RESULT_T NMSAPI NMS_V5Initialize (
                                NMS_V5_BOARD_FAMILY_T board_family,
                                void *init_parms);
/* Enable/disable tracing */
NMS_V5_RESULT_T NMSAPI NMS_V5SetTrace (
                                NMS_V5_TRACEMASK_T trace_mask, 
                                NMS_V5_TRACE_CALLBACK_T user_trace_callback,                                
                                void *user_trace_buffer, 
                                DWORD user_trace_buffersize,
                                char *user_file_name);
/* Exit this library */
NMS_V5_RESULT_T NMSAPI NMS_V5Exit ();
/* Provision the HDLC channels for the specified interface */
NMS_V5_RESULT_T NMSAPI NMS_V5ProvisionInterface (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                DWORD num_e1s,
                                NMS_V5_E1_LOCATION_T *e1_loc_array,
                                NMS_V5_E1_STATUS_CALLBACK_T e1_status_callback,
                                DWORD num_channels,
                                NMS_V5_CHANNEL_LOCATION_T *channel_loc_array,
                                NMS_V5_CHANNEL_CALLBACK_T channel_callback, 
                                void *channel_rx_buffer,
                                DWORD channel_rx_buffersize);
/* Provision the standby variant for the specified interface */
NMS_V5_RESULT_T NMSAPI NMS_V5ProvisionStandbyVariant (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                DWORD num_e1s,
                                NMS_V5_E1_LOCATION_T *e1_loc_array,
                                NMS_V5_E1_STATUS_CALLBACK_T e1_status_callback,
                                DWORD num_channels,
                                NMS_V5_CHANNEL_LOCATION_T *channel_loc_array,
                                NMS_V5_CHANNEL_CALLBACK_T channel_callback, 
                                void *channel_rx_buffer,
                                DWORD channel_rx_buffersize);
/* Destroy the specified interface. */
NMS_V5_RESULT_T NMSAPI NMS_V5DestroyInterface (
                                NMS_V5_INTERFACE_ID_T interfaceId);
/* Destroy the specified standby variant interface. */
NMS_V5_RESULT_T NMSAPI NMS_V5DestroyStandbyVariant (
                                NMS_V5_INTERFACE_ID_T interfaceId);
/* Add channel to specified interface. */
NMS_V5_RESULT_T NMSAPI NMS_V5AddChannel (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_CHANNEL_LOCATION_T channel_loc);
/* Delete channel from specified interface */
NMS_V5_RESULT_T NMSAPI NMS_V5DeleteChannel (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_CHANNEL_LOCATION_T channel_loc);
/* Add E1 link to specified interface. */
NMS_V5_RESULT_T NMSAPI NMS_V5AddE1 (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_E1_LOCATION_T e1_loc);
/* Delete E1 link from specified interface */
NMS_V5_RESULT_T NMSAPI NMS_V5DeleteE1 (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_E1_LOCATION_T e1_loc);
/* Switch over to standby interface */
NMS_V5_RESULT_T NMSAPI NMS_V5SwitchOverVariantData (
                                NMS_V5_INTERFACE_ID_T interfaceId);
/* Start the physical layer of the provisioned interface. */
NMS_V5_RESULT_T NMSAPI NMS_V5StartInterface (
                                NMS_V5_INTERFACE_ID_T interfaceId);
/* Stop the physical layer of the provisioned interface. */
NMS_V5_RESULT_T NMSAPI NMS_V5StopInterface (
                                NMS_V5_INTERFACE_ID_T interfaceId);
/* Send a LAPV frame to the NMS layer 1 interface */
NMS_V5_RESULT_T NMSAPI NMS_V5PhSendData (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_CHANNEL_LOCATION_T channel_loc,
                                DWORD number_bytes,
                                void *lapv_data);
/* Send a SA7 bit to the NMS layer 1 interface */
NMS_V5_RESULT_T NMSAPI NMS_V5SendSA7Bit (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_E1_LOCATION_T e1_loc,
                                NMS_V5_SA7_VALUE_T sa7_value);
/* Get statistics for a specified HDLC Channel. */
NMS_V5_RESULT_T NMSAPI NMS_V5GetChannelStatistics (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_CHANNEL_LOCATION_T channel_loc,
                                NMS_V5_CHANNEL_STATISTICS_T *channel_stat);
/* Reset statistics structure for the specified HDLC channel. */
NMS_V5_RESULT_T NMSAPI NMS_V5ResetChannelStatistics (
                                NMS_V5_INTERFACE_ID_T interfaceId,
                                NMS_V5_CHANNEL_LOCATION_T channel_loc);
/* Get the status for the specified E1 link. */
NMS_V5_RESULT_T NMSAPI NMS_V5GetE1Status (
                                NMS_V5_INTERFACE_ID_T interfaceId, 
                                NMS_V5_E1_LOCATION_T e1_loc,
                                NMS_V5_E1_STATUS_T *e1_status);
/* Reset the status structure for the specified E1 link. */
NMS_V5_RESULT_T NMSAPI NMS_V5ResetE1Status (
                                NMS_V5_INTERFACE_ID_T interfaceId, 
                                NMS_V5_E1_LOCATION_T e1_loc);

/*==========================================================================*/
#ifdef __cplusplus
}
#endif
#endif /*_NMS_V5LIB_H_*/
/*=============================== [eof] ====================================*/
